<%@ Page Title="Sys_CorporateAccounts List" Language="C#" AutoEventWireup="true" CodeBehind="Sys_CorporateAccountsList.aspx.cs" Inherits="Youz.CreditRepay.Manage.Sys_CorporateAccountsList" %>

<script>
    //loadCSS("assets/plugins/gritter/css/jquery.gritter.css");

    var requireJS = [
        //"assets/plugins/gritter/js/jquery.gritter.min.js"
    ];

    loadJS(requireJS);
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading" data-original-title>
                <h2><i class="fa fa-align-justify"></i><span style="font-size: 16px; padding-right: 15px;"><%: R(LanguageModule.Sys_CorporateAccounts, "Sys_CorporateAccounts", "Sys_CorporateAccounts") %></span></h2>
                <div class="panel-actions"></div>
            </div>
            <div class="panel-body">
                <div class="alert alert-danger" style="display: none;">
                    <button type="button" class="close" data-dismiss="alert">×</button><strong><i class="fa fa-warning"></i></strong><span class="content"></span>
                </div>
                <%--                <div class="col-sm-4">
                    <div class="form-group">
                        <div class="input-group">
                            <input type="email" id="input2-group2" name="input2-group2" class="form-control" placeholder="Search..."><span class="input-group-btn">
                                <button type="button" class="btn btn-primary">
                                <i class="fa fa-search "></i>
                                <%: R(LanguageModule.M_Common, "Query") %></button></span>
                        </div>
                    </div>
                </div>--%>
                <div class="col-sm-12">
                    <div class="form-group">
                        <a href="#" class="btn btn-info" onclick="loadPage('Sys/Sys_CorporateAccountsItem.aspx')"><i class="fa fa-plus"></i>
                            <%: R(LanguageModule.M_Common, "Add") %></a>
                        <a href="#" class="btn btn-info" id="btnEdit"><i class="fa fa-edit "></i>
                            <%: R(LanguageModule.M_Common, "Edit") %></a>
                        <a href="#" class="btn btn-info" id="btnDelete"><i class="fa fa-trash-o "></i>
                            <%: R(LanguageModule.M_Common, "Delete") %></a>
                    </div>
                </div>
                <table id="table" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var dt;

    $(function () {

        dt = $('#table').DataTable({
            "ajax": {
                "url": 'Sys/Handlers/Sys_CorporateAccountsHandler.ashx?type=list',
                "type": "POST",
                "dataSrc": "data",
                "data": function (d) {
                }
            },
            "columns": [
                    { "data": 'RowIndex', "title": "#" },
                    { "data": 'AccountsId', "title": "<%: R(LanguageModule.Sys_CorporateAccounts, "AccountsId", "编号") %>", visible: false },
                    { "data": 'Country', "title": "<%: R(LanguageModule.Sys_CorporateAccounts, "Country", "所属国家") %>" },
                    { "data": 'BankName', "title": "<%: R(LanguageModule.Sys_CorporateAccounts, "BankName", "银行名称") %>" },
                    { "data": 'BankAccountNo', "title": "<%: R(LanguageModule.Sys_CorporateAccounts, "BankAccountNo", "银行账户号") %>" },
                    { "data": 'BankAccountName', "title": "<%: R(LanguageModule.Sys_CorporateAccounts, "BankAccountName", "银行賬戶名") %>" },
                    { "data": 'Status', "title": "<%: R(LanguageModule.M_Common, "Status", "状态") %>", render: fnumber },
                    { "data": 'Creator', "title": "<%: R(LanguageModule.Sys_CorporateAccounts, "Creator", "创建人") %>" },
                    { "data": 'CreateTime', "title": "<%: R(LanguageModule.Sys_CorporateAccounts, "CreateTime", "创建时间") %>" },
                    { "data": 'Modifier', "title": "<%: R(LanguageModule.Sys_CorporateAccounts, "Modifier", "修改人") %>" },
                    { "data": 'ModifyTime', "title": "<%: R(LanguageModule.Sys_CorporateAccounts, "ModifyTime", "修改时间") %>" },
            ]
        });

        //delete selected row
        $('#btnDelete').click(function () {
            if ($('#table tbody tr.selected').length > 0) {
                jconfirm("<%: R(LanguageModule.M_Common, "DeleteConfirm") %>", function () {
                    //console.log(dt.row('.selected').data());
                    $.post("Sys/Handlers/Sys_CorporateAccountsHandler.ashx?type=delete", { AccountsId: dt.row('.selected').data().AccountsId }, function (data) {
                        if (data) {
                            if (data.isSuccess) {
                                dt.ajax.reload();

                                $.gritter.add({
                                    title: '<%: R(LanguageModule.M_Common, "TipSuccess") %>',
                                      text: data.message,
                                      class_name: 'gritter-success'
                                  });

                                  $('#table tbody tr.selected').remove();
                              }
                          }
                      }, "json");
                });
              }
              else {
                  $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                $(".alert").show();
            }
        });

        //delete selected row
        $('#btnEdit').click(function () {
            if ($('#table tbody tr.selected').length > 0) {
                loadPage("Sys/Sys_CorporateAccountsItem.aspx?AccountsId=" + dt.row('.selected').data().AccountsId);
            }
            else {
                $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                $(".alert").show();
            }
        });

    });
    function fnumber(value, row) {

        return value == '1' ? '<span style="color:green"><%=R(LanguageModule.M_Common, "Enable", "啟用") %></span>' : '<span style="color:red"><%=R(LanguageModule.M_Common, "Disable", "禁用") %></span>';

      }
</script>
